﻿//////////////////////////////////////////////////////////////////////////
// FileName:fmSecruityAnalysisMeetingList.aspx
// CreateBy:DragonXiong
// CreateDate:2010-05-27
// Description:
//		 Secruity Analysis Meeting List
//      
// Modify Log:
//	
// Copyright:
/////////////////////////////////////////////////////////////////////////
using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Auto.Web.Common;
using Auto.Components;
using Model = Auto.Data.BusMan.Model;
using BLL = Auto.Data.BusMan.BLL;

namespace Auto.BusMan
{
    public partial class fmSecurityTrainingList : System.Web.UI.Page
    {
        DataTable dt;
        BLL.SecurityTraining bll = new BLL.SecurityTraining();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }

        private void InitPage()
        {
            this.ucDDLKeepDiv1.InitControl();
            Display();
        }

        #region --BindData--
        private void Display()
        {
            if (!string.IsNullOrEmpty(ucDDLKeepDiv1.SelectedValue))
            {
                dt = bll.GetList(" AND " + Model.SecurityTraining.FIELD_RecDivID + " ='" + ucDDLKeepDiv1.SelectedValue + "'");
            }
            else
            {
                dt = bll.GetList("");
            }
            Session["fmSecurityTrainingList.dt"] = dt;
            BindData();
        }

        #endregion --BindData--

        #region Event

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string strWhere = string.Empty;
            if (!string.IsNullOrEmpty(ucDDLKeepDiv1.SelectedValue))
            {
                strWhere += " AND " + Model.SecurityTraining.FIELD_RecDivID + " ='" + ucDDLKeepDiv1.SelectedValue + "'";
            }
            if (!string.IsNullOrEmpty(txtItem.Text))
            {
                strWhere +=" AND "+ Model.SecurityTraining.FIELD_Item + "='" + txtItem.Text + "'";
            }
            dt = bll.GetList(strWhere);
            Session["fmSecurityTrainingList.dt"] = dt;
            BindData();
        }

        #endregion Event


        #region --GridView--
        protected void BindData()
        {
            GridView1.DataSource = (DataTable)Session["fmSecurityTrainingList.dt"];
            GridView1.DataBind();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.GridView1.PageIndex = e.NewPageIndex;
            BindData();
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }

        protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
        {

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string docID = (string)GridView1.DataKeys[e.RowIndex].Value;
            bll.Delete(docID);
            Display();
        }

        #endregion --GridView--

        public string CutString(object o)
        {
            if (o != null && o.ToString().Length > 6)
            {
                return o.ToString().Substring(0, 6) + "...";
            }
            return o.ToString();
        }

    }
}